package com.pow.controller;

import com.pow.entity.User;
import com.pow.service.UserService;
import com.pow.util.FenyeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

/**
 * @author 赵祺
 * @date 2020/4/13 17:09
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping
    public FenyeUtil<User> getAllUser(User user, Pageable pageable, Integer page){
        FenyeUtil<User> allPageByUser = userService.findAllPageByUser(user, pageable, page);
        return  allPageByUser;
    }
    @PostMapping
    public  String AddAndUpdateUser(User user){
        return  userService.AddAndUpdateUser(user);
    }
    @DeleteMapping
    public  String DeleteUser(String id){
        return  userService.deleteUser(id);
    }
    @GetMapping("/getNotRole")//获取未获得角色信息
    public Object getNotRole(String id) {
    	return userService.getNotRoleById(id);
    }
   
    @PutMapping("/commit")
    public Integer commitUser_Role(String uid,String rid) {
    	// userService.commitUser_Role(uid, rid);
    	// userService.getUser_Role(uid, rid);
    	// userService.addUser_Role(uid, rid);
    	// userService.deleteUser_Role(uid, rid);
    	// userService.getRidsByUid(uid).size();
    	return userService.commitUser_Role(uid, rid);
    }
}
